import Utils from "@/utils/utils.js"
//获取用户信息 权限
export function getUserInfo() {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getmemberInfo`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}
//获取商户信息
export function getShopInfo() {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getMerchantInfo`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//获取商户审核状态
export function getShopState(shopid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `api1/ShopDetail?id=${shopid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//修改商户信息
export function editMerchantInfo(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/editMerchantInfo`,
			method: 'PUT',
			data: params
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

// 获取商户详情信息
export function getMerchantInfo(tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getMerchantInfo/${tMerchantid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}


//新增商品
export function goodsAdd(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/addCommodityinfo`,
			method: 'POST',
			data: params
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//修改商品
export function goodsEdit(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/editCommodityinfo`,
			method: 'PUT',
			data: params
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//商家奖品设置
export function setPrizeRule(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/setPrizeRule`,
			method: 'POST',
			data: params
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//查询抽奖奖项
export function getPrizeRule(tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getRuleList?tMerchantid=${tMerchantid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//开始抽奖
export function startPrize(tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/startLottery/${tMerchantid}`,
			method: 'POST',
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//新增抽奖记录
export function addLotteryRecord(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/addLotteryRecord`,
			method: 'POST',
			data: params
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}


//查询抽奖记录
export function getLotteryRecordlist(tMemberid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getLotteryRecordlist?tMemberid=${tMemberid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//商户-查询抽奖记录
export function getLotteryRecordlistByMerchant(tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getLotteryRecordlist?tMerchantid=${tMerchantid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//我的访客
export function getVisitorList(pageNum, pageSize, tMerchantid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/getVisitorList?pageNum=${pageNum}&pageSize=${pageSize}&tMerchantid=${tMerchantid}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}